<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>AOS</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="js/config.js"></script>
</head>

<body>

<div class="x-body">
    <table class="layui-table" id="table"></table>
</div>

<script>
    //数据表数据加载
    layui.use('table', function () {
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#table'
            , height: 600
            // , width: ''
            , url: 'http://' + IPADDRESS + ':' + PORT + '/activity/getLogList' //数据接口
            , method: 'post'
            , request: {
                pageName: 'page_num' //页码的参数名称，默认：page
                , limitName: 'page_size' //每页数据量的参数名，默认：limit
            }
            , parseData: function (res) { //res 即为原始返回的数据

                $.each(res.body.log_list, function (i, val) {

                    if (val.behaviour == '2') {
                        val.behaviour = '修改';
                    } else {
                        val.behaviour = '新增';
                    }
                    if (val.activity_type == '1') {
                        val.activity_type = '优惠券活动';
                    }
                    if (val.activity_type == '2') {
                        val.activity_type = '转盘活动';
                    }
                });

                return {
                    "code": res.header.res_code, //解析接口状态
                    "msg": res.header.message, //解析提示文本
                    "count": res.body.total, //解析数据长度
                    "data": res.body.log_list //解析数据列表
                };
            }
            , response: {
                statusCode: 200000 //规定成功的状态码，默认：0
            }
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'log_key', title: '编号',width:'20%'}
                , {field: 'behaviour', title: '行为',width:'20%'}
                , {field: 'manager_key', title: '操作人',width:'20%'}
                , {field: 'time', title: '时间',width:'20%'}
                , {field: 'activity_type', title: '活动类型'}
            ]]
            , limit: 5
            , limits: [5, 10, 20]
            , loading: true
        });
    });
</script>
</body>
</html>
